package com.sscl.baselibrary.dialog

import android.app.Dialog
import android.content.Context
import android.content.DialogInterface
import android.os.Bundle

abstract class BaseDialog: Dialog {

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     * 构造方法
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    constructor(context: Context) : this(context, 0)

    constructor(context: Context, themeResId: Int) : super(context, themeResId)

    constructor(
        context: Context,
        cancelable: Boolean,
        cancelListener: DialogInterface.OnCancelListener?
    ) : super(context, cancelable, cancelListener)

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     * 重写方法
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayout())
        doBeforeInitOthers()
        initViewData(savedInstanceState)
        initOtherData()
        initEvents()
        doAfterAll()
    }

    /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
     *
     * 抽象方法
     *
     * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

    abstract fun getLayout(): Int
    abstract fun doBeforeInitOthers()
    abstract fun initViewData(savedInstanceState: Bundle?)
    abstract fun initOtherData()
    abstract fun initEvents()
    abstract fun doAfterAll()
}